package com.jinmdz.fmis.mapper.mapper;

import com.jinmdz.fmis.mapper.entity.SystemAreaEntity;
import com.jinmdz.fmis.mapper.mapper.provider.SystemAreaProvider;
import org.apache.ibatis.annotations.*;

import java.util.ArrayList;

/**
 * 行政区划表Mapper
 *
 * @author generator
 * @date 2020-05-18 10:52
 */
public interface SystemAreaMapper {

    /**
     * 增加SystemArea
     *
     * @param entity 数据实体
     * @return
     * @author generator
     * @date 2020-05-18 10:52
     */
    @InsertProvider(type = SystemAreaProvider.class, method = "insertSystemArea")
    @Options(useGeneratedKeys = true, keyProperty = "entity.id", keyColumn = "id")
    void insertSystemArea(@Param("entity") SystemAreaEntity entity);

    /**
     * 删除SystemArea
     *
     * @param id             主键
     * @param modifiedUserId 修改用户外键
     * @param version        版本号
     * @return
     * @author generator
     * @date 2020-05-18 10:52
     */
    @Update(" update system_area set deleted = 1,modified_user_id = #{modifiedUserId},version = unix_timestamp(now()) where id = #{id} and version = #{version} and unmodified = 0 and deleted = 0 ")
    void deletedForSystemArea(@Param("id") Integer id, @Param("modifiedUserId") Integer modifiedUserId, @Param("version") Long version);

    /**
     * 修改SystemArea
     *
     * @param entity 数据实体
     * @return
     * @author generator
     * @date 2020-05-18 10:52
     */
    @UpdateProvider(type = SystemAreaProvider.class, method = "updateSystemArea")
    void updateSystemArea(@Param("entity") SystemAreaEntity entity);

    /**
     * 查询SystemArea实体
     *
     * @param id 主键
     * @return SystemAreaEntity
     * @author generator
     * @date 2020-05-18 10:52
     */
    @Select(" select id,deleted,parent_id,parent_code,area_code,area_name,area_name_abbr,disable_state,as_province_city_county,sort,remark,funeral_parlour_code,create_user_id,gmt_create,unmodified,modified_user_id,gmt_modified,version from system_area where id = #{id} and deleted = 0 limit 1 ")
    SystemAreaEntity getSystemAreaById(@Param("id") Integer id);

    /**
     * 查询SystemArea列表
     *
     * @param entity 数据实体
     * @return SystemAreaEntity
     * @author generator
     * @date 2020-05-18 10:52
     */
    @SelectProvider(type = SystemAreaProvider.class, method = "listSystemArea")
    ArrayList<SystemAreaEntity> listSystemArea(@Param("entity") SystemAreaEntity entity);
}